/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ch.repit.aglaja.client.contacts;

import ch.repit.rwt.client.AttributeDef;
import ch.repit.rwt.client.AttributeDef.Feature;
import ch.repit.rwt.client.AttributeType;
import ch.repit.rwt.client.BentoDef;
import ch.repit.rwt.client.ObjectRef;
import ch.repit.rwt.client.ui.Page;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author tc149752
 */
public class TagDef extends BentoDef {

    public static final String TYPE = "Tag";

    public static final String ATTR_NAME = "name";
    public static final String ATTR_DESCRIPTION = "description";
    public static final String ATTR_ADDRESSES = "addressRefs";

    private static Set<AttributeDef> attrDefs = new HashSet<AttributeDef>();
    static {
        attrDefs.add(new AttributeDef(ATTR_NAME, AttributeType.STRING, Feature.MANDATORY, Feature.UNIQUE));
        attrDefs.add(new AttributeDef(ATTR_DESCRIPTION, AttributeType.STRING));
        attrDefs.add(new AttributeDef(ATTR_ADDRESSES, AttributeType.STRING_LIST, Feature.NOT_AUDITABLE));
            // not auditable because easily longer than 500 chars...
    }


    /**
     * To be used server-side, where categories are just an attribute
     */
    public TagDef() {
        super(attrDefs);
    }

    public String getType() {
        return TYPE;
    }
    public String getTypeLabel() {
        return "Tag";
    }

    public String getJdoClassName() {
        return "ch.repit.aglaja.server.contacts.Tag";
    }

    @Override
    public String getDistinguishedAttribute() {
        return ATTR_NAME;
    }

    @Override
    public Page getViewPage(ObjectRef oref) {
        return new TagDetailsPage(oref);
    }

}
